﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class aspx_admin_teacher_insert : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        FileUpload fu = this.FormView1.FindControl("fu") as FileUpload;
        if (fu.HasFile)
        {
            try
            {
                Guid id = Guid.NewGuid();
                string filename = id.ToString() + System.IO.Path.GetExtension(fu.FileName);
                e.Values["虚目录"] = string.Format("~/images/teacher/small/{0}", filename);
                WebHelper.WebControls.UploadFile(
                         fu,
                         "~/images/teacher/small/",
                         new string[] { ".jpg", ".png", ".gif", ".jpeg", ".bmp" },
                         filename,
                         false,
                         int.MaxValue);
            }
            catch (Exception)
            {
                throw;
            }
        }
        WebHelper.MessageBox.Show("添加成功！");
    }
}